<?php

/**
 * @category   mediad2
 * @package    Mediad2_Service
 */
class Mediad2_Service_Admin_Log extends Mediad2_Service_Abstract
{
	/**
	 * 初始化
	 */
	public function init()
	{
		$this->setMapper('Mediad2_Mapper_Log');
		$this->setModel('Mediad2_Model_Log');
	}
	
	/**
	 * log
	 * @param array $data
	 * @return Mediad_Model_Result
	 */
	public function log(array $data)
	{
		if (count($data)==0) {
			return $this->returnResult(Mediad2_Model_Result::CODE_FAILURE,"Missing parameter");
		}
		
		$model = new Mediad2_Model_Log();
		if (isset($data['uid'])) $model->setDid($data['uid']);
		if (isset($data['busid'])) $model->setBusid($data['busid']);
		if (isset($data['bustype'])) $model->setBustype($data['bustype']);
		if (isset($data['content'])) $model->setContent($data['content']);
		$model->setAddtime(time());
		
		return $this->insert($model);
	}
	
}